<?php
	$code_index = $params[0];

	if($_SERVER["REQUEST_METHOD"]=='POST') {
		$title			= strip_tags($_POST['title']);
		$code			= strip_tags($_POST['code']);
		$discount		= strip_tags($_POST['discount']);
		$ip				= getUserIP();

		$sql = "UPDATE `tbl_code` SET `title` = '$title', `code` = '$code', `discount` = '$discount', `ip` = '$ip' WHERE `code_index` = '$code_index' LIMIT 1;";
		mysql_query($sql);
		redirect('../');
		exit;
	}

	$sql = "SELECT * FROM `tbl_code` WHERE  `code_index` = '$code_index' LIMIT 1";
	$query = mysql_query($sql);
	while($result = mysql_fetch_assoc($query)) {
		$title		= $result['title'];
		$code		= $result['code'];
		$discount	= $result['discount'];
	}
	mysql_free_result($query);
?>